package com.hdc.sell.utils;

import com.hdc.sell.enums.CodeEnum;

/**
 * @author 郭丽然
 * @program: sell
 * @date 2020/6/10 9:51
 * 功能：
 */
public class EnumUtil {
    //根据状态码code获取对应的枚举对象
    public static <T extends CodeEnum> T getByCode(Integer code,
                                                   Class<T> enumClass) {
        for (T each : enumClass.getEnumConstants()) {
            if (code.equals(each.getCode())) {
                return each;
            }
        }
        return null;
    }
}
